package org.PaperBase {

	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageQuality;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.scenes.*;
	import org.papervision3d.utils.InteractiveSceneManager;
	import org.papervision3d.utils.InteractiveSprite;

	public class FreshView extends Sprite
	{
		protected var container 				:Sprite;
		protected var default_scene     		:InteractiveScene3D;
		protected var default_camera   			:Camera3D;
		protected var ism						:InteractiveSceneManager;
		
		public function FreshView()
		{
			//init();
		}

		public function init():void {
			initStage();
			initScene();
			initCamera();
			init3D();
			init2D();
			initEvents();			
		}
		
		protected function initStage():void{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			stage.quality = StageQuality.BEST;
		}
		
		protected function initScene():void{
			container = new InteractiveSprite();
			addChild(container);
			container.name = "mainCont";
			container.x = stage.stageWidth*.5;
			container.y = stage.stageHeight*.5;
			default_scene = new InteractiveScene3D(container);
			ism = default_scene.interactiveSceneManager;
		}
		
		protected function initCamera():void{
			default_camera = new Camera3D();
			/*with(default_camera){
				x=0;
				y=0;
				z=0;
			}*/
		}
		
		protected function init2D():void{
			
		}
	
		protected function init3D():void {
		}
		
		protected function initEvents():void{
			addEventListener(Event.ENTER_FRAME, renderTick);
		}

		private function renderTick(event:Event):void {
			processFrame();
			default_scene.renderCamera(default_camera);
		}
		
		protected function processFrame():void{
			
		}
		
	}
}
